package ABC;

import java.util.Scanner;

public class CHIHUONIANNENG { public static void main(String[] args) {
    Scanner input=new Scanner(System.in);
    System.out.println("*****欢使用”吃货联盟”*******");
    String[]name=new String[4];
    String[]caiping={"红烧带鱼","鱼香肉丝","时令水果","新鲜蔬菜"};
    Double []money={38.0,28.0,18.0,15.0};
    int []zai=new int[4];
    double[]time=new double[4];
    boolean[]states=new boolean[4];
    double[]sunmony=new double[4];
    String[]adress=new String[4];
    String[]caipingfenshu=new String[4];
    int a=-1;//判断是否输入0时结束；
    int b=0;//用户每次进行选择；
    boolean f=false;
    do{
        System.out.println("******************");
        System.out.println("1我要订餐");
        System.out.println("2查看餐袋");
        System.out.println("3签收订单");
        System.out.println("4删除订单");
        System.out.println("5我要点赞");
        System.out.println("6退出系统");
        System.out.println("******************");
        System.out.print("请选择：");
        b=input.nextInt();
        switch (b){
            case 1:
                System.out.println("我要订餐");
                for(int i=0;i<name.length;i++){
                    if(name[i]==null){
                        System.out.println("请输入您的姓名：");
                        String name1=input.next();
                        System.out.println("序号\t菜品名\t价格");
                        for(int j=0;j<caiping.length;j++){
                            System.out.print((j+1)+"\t");
                            System.out.print(caiping[j]+" ");
                            System.out.println(money[j]+" ");

                        }
                        System.out.println("请输入你的菜品序号");
                        int mun=input.nextInt();
                        System.out.println(caiping[mun-1]+" "+money[mun-1]);
                        System.out.println("请问你要几分:");
                        int mun2=input.nextInt();
                        System.out.println(caiping[mun-1]+mun2+"份");
                        double money1=money[mun-1]*mun2;
                        if(money1>50){
                            money1=money1;
                        }
                        else {
                            money1=money1+6.0;
                        }
                        System.out.println("您总共花了"+money1);
                        System.out.println("请输入你的地址：");
                        String adress1=input.next();
                        System.out.println("您的地址为"+adress1);
                        System.out.println("请您输入你的配送时间：");
                        double time1=input.nextDouble();
                        while (time1>20.0||time1<8.0){
                            System.out.println("请您在次选择配送时间：");
                            time1=input.nextDouble();
                        }
                        System.out.println("恭喜您点餐成功");
                        name[i]=name1;
                        time[i]=time1;
                        sunmony[i]= money1;
                        caipingfenshu[i]=caiping[mun-1]+mun2+"份";
                        states[i]=false;
                        adress[i]=adress1;

                        break;
                    }
                }
                break;
            case 2:
                System.out.println("查看餐袋");
                System.out.println("序号\t姓名\t时间\t地址\t状态\t总金额");
                for(int i=0;i<time.length;i++){
                    if(time[i]==0){
                        break;
                    }
                    else {
                        System.out.println((i+1)+"\t"+name[i]+"\t"+caipingfenshu[i]+"\t"+adress[i]+"\t"+states[i]+"\t"+sunmony[i]+"\t"+time[i]+"\t"+zai[i]);
                    }
                }
                break;
            case 3:
                System.out.println("签收订单");
                int p=0;
                System.out.println("序号\t姓名\t时间\t地址\t状态\t总金额");
                for(int i=0;i<time.length;i++){
                    if(time[i]==0){
                        break;

                    }
                    else {
                        p++;
                        System.out.println((i+1)+"\t"+name[i]+"\t"+caipingfenshu[i]+"\t"+adress[i]+"\t"+states[i]+"\t"+sunmony[i]+"\t"+time[i]+"\t"+zai[i]);
                    }
                }System.out.println("请选择您要签收的订单");
                int mun=input.nextInt();
                while (mun>p&&states[mun-1]==false) {
                    System.out.println("请在问一次");
                }
                states[mun-1]=true;
                System.out.println(states[mun-1]);
                System.out.println("恭喜您签收成功");

                break;
            case 4:
                System.out.println("删除订单");System.out.println("签收订单");
                int c=0;
                System.out.println("序号\t姓名\t时间\t地址\t状态\t总金额");
                for(int i=0;i<time.length;i++){
                    if(time[i]==0){
                        break;

                    }
                    else {
                        c++;
                        System.out.println((i+1)+"\t"+name[i]+"\t"+caipingfenshu[i]+"\t"+adress[i]+"\t"+states[i]+"\t"+sunmony[i]+"\t"+time[i]+"\t"+zai[i]);
                    }
                }
                System.out.println("请输入你要删除的订单");
                int mum=input.nextInt();
                while (mum>c&&states[mum-1]==false){
                    System.out.println("请在输入一次");
                    mum=input.nextInt();
                }
                for(int i=mum;mum<time.length-1;mum++){
                    time[mum-1]=time[mum];
                    states[mum-1]=states[mum];
                    sunmony[mum-1]=sunmony[mum];
                    adress[mum-1]=adress[mum];
                    caipingfenshu[mum-1]=caipingfenshu[mum];
                    name[mum-1]=name[mum];
                }
                time[time.length-1]=0;
                states[time.length-1]=false;
                sunmony[time.length-1]=0;
                adress[time.length-1]=null;
                caipingfenshu[time.length-1]=null;
                name[time.length-1]=null;
                for(int i=0;i<time.length;i++){
                    System.out.println((i+1)+"\t"+name[i]+"\t"+caipingfenshu[i]+"\t"+adress[i]+"\t"+states[i]+"\t"+sunmony[i]+"\t"+time[i]+"\t"+zai[i]);
                }
                break;
            case 5:
                System.out.println("我要点赞");


                System.out.println("序号\t菜品名\t价格");
                for(int j=0;j<caiping.length;j++) {
                    System.out.print((j + 1) + "\t");
                    System.out.print(caiping[j] + " ");
                    System.out.println(money[j] + " ");
                }
                System.out.println("请输入你的菜品序号");
                int mun1=input.nextInt();
                while(mun1>4){
                    System.out.println("请在输入一次");
                    mun1=input.nextInt();
                }
                zai[mun1-1]=(zai[mun1-1]+1);
                System.out.println(zai[mun1-1]);
                break;
            case 6:
                System.out.println("退出系统");
                f=true;
                break;
            default:
                f=true;
                break;

        }if(f==true){
            break;
        }else {
            System.out.println("是否结束");
            a=input.nextInt();
        }


    }
    while (a==0);{
        System.out.println("欢迎下次使用");
    }
}
}
